
compiler_plugin "FS.Plugins.Ext.DateNamed"
{
    desc            =   "Allows representation of dates used calendar names such as Jan 1 2012, or January 1st 2012";
    examples        =   [ 'jan 1st', 'Jan 1st', 'Jan 1', 'Jan 1 2012', 'Jan 1st 2012', 'January 1st, 2012' ];
    type            =   "expr";
    precedence      =   1;  
    grammar_match   =   "$month:@starttoken.value $day:@number.tvalue $dayend:( st | nd | rd | th )? ( ','?  $year:@number.tvalue )? ( at $time:@time.tvaluestring )?" 
    defaults        =   {  "dayValue" : 1, "yearValue" : -1, "timeValue" : "0" };   
    start_tokens    =   {  
                            "jan"        : 1,  "feb"      : 2, "mar"   : 3,    "apr"   : 4,  "may" : 5,      "jun"  : 6,     "jul"  : 7,     "aug"    : 8,   "sep"       : 9,    "oct"     : 10,  "nov"      : 11, "dec"      : 12,             
                            "Jan"        : 1,  "Feb"      : 2, "Mar"   : 3,    "Apr"   : 4,  "May" : 5,      "Jun"  : 6,     "Jul"  : 7,     "Aug"    : 8,   "Sep"       : 9,    "Oct"     : 10,  "Nov"      : 11, "Dec"      : 12,
                            "january"    : 1,  "february" : 2, "march" : 3,    "april" : 4,  "may" : 5,      "june" : 6,     "july" : 7,     "august" : 8,   "september" : 9,    "october" : 10,  "november" : 11, "december" : 12,
                            "January"    : 1,  "February" : 2, "March" : 3,    "April" : 4,  "May" : 5,      "June" : 6,     "July" : 7,     "August" : 8,   "September" : 9,    "October" : 10,  "November" : 11, "December" : 12 
                        };                        
    build           =   function(args)    
                        {       
                            var month = args["monthValue"];
                            var day = args["dayValue"];
                            var year = args["yearValue"];
                            var time = args["timeValue"];          
                            var token = args["month"];
                            return sys.compiler.ToConstantDate(month, day, year, time, token)
                        }
}